﻿using Compass.Wasm.Shared;
using Compass.Wasm.Shared.Purchases;
using System.Net.Http.Json;

namespace Compass.Wasm.Client.Services.Purchases;
public interface INavInvValuationService:IBaseService<NavInvValuationDto>
{
    Task<List<NavMonthlyValuationDto>> GetMonthlyValuationsAsync();
}
public class NavInvValuationService:BaseService<NavInvValuationDto>,INavInvValuationService
{
    #region ctor
    private readonly HttpClient _http;
    private const string ServiceName = "NavInvValuation";
    public NavInvValuationService(HttpClient http) : base(http, ServiceName)
    {
        _http = http;
    } 
    #endregion


    public async Task<List<NavMonthlyValuationDto>> GetMonthlyValuationsAsync()
    {
        var response = await _http.GetFromJsonAsync<ApiResponse<List<NavMonthlyValuationDto>>>($"api/{ServiceName}/MonthlyValuations");
        return response.Status ? response.Result : new List<NavMonthlyValuationDto>();
    }
}